<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="vue2.2.js"></script>
</head>
<body>
<div id="app">
    <counter :count="0" @inc="handleInc"></counter>
    <counter :count="1"></counter>
    <div>{{total}}</div>
</div>
<script>
    var counter = {
        props: ['count'],
        data: function () {
            return {
                number: this.count
            }
        },
        template: '<div @click="handleClick">{{number}}</div>',
        methods: {
            handleClick: function () {
                this.number++;
                this.$emit('inc', 1)
            }
        }
    }
    var vm = new Vue({
        el: "#app",
        data: {
            total: 5
        },
        components: {
            counter
        },
        methods: {
            handleInc: function (a) {
                this.total += a
            }
        }
    })
</script>
</body>
</html>